<script setup lang="ts">
import { ref,onMounted, onUnmounted, computed } from 'vue';
import type { DocForm } from '@/types/workflow';
import request from '@/api/request.ts'
import dialog from '@/util/DialogTool';
import CarInfoItem from '@/components/carInfo.vue';
import SectionTitle from '@/components/SectionTitle.vue';
import { useRoute } from 'vue-router';
import ColorItem from '@/components/ColorItem.vue';
import type { CarInfo, CarParkQueryResult } from '@/types/common';
import CarLogList from './carLogList.vue';

var pageNo = 1;
const asynDate = ref();
const carInfo = ref<CarInfo>();
const taskList = ref<DocForm[]>()
const loading = ref(false)
const refreshLoading = ref(false)
const route = useRoute();

const plateNo = ref();

onMounted(()=>{
    plateNo.value = route.query.no + '';
    init()    
});

const init = ()=>{
    //刷新列表
    pageNo = 1;    
    taskList.value = [];    

    getList();        
}

const getList = ()=>{

    dialog.showLoading();

    var no = route.query.no;
    var id = route.query.id;

    request.get<CarParkQueryResult>('/query/queryCarPark',{pageNo,id})
    .then((result)=>{
        dialog.closeToast();
        loading.value = false;
        refreshLoading.value = false;

        if(result.data){
            asynDate.value = result.data.asynDate
            result.data.carInfo.CPH = no+"";
            carInfo.value = result.data.carInfo;
        }
    }).catch(()=>{
        loading.value = false;
        refreshLoading.value = false;
        dialog.closeToast();
    });

    
}


</script>

<template>
<div class="favo">
    <div class="favoPagetitle">
        车辆详细信息
    </div>

    <div class="carBakInfo">
        <SectionTitle text="车辆备案信息" />
    </div>

    <div class="carInfoContent">
        <ColorItem color="#FFA000" class="searchItem" :colorBorder="false"  style="border-radius: 0;border:none">
            <CarInfoItem :value="carInfo" :link="false"/>
        </ColorItem>
    </div>

                        

    

    <div class="carBakInfo">
        <SectionTitle text="进出记录" />
    </div>

    <CarLogList :plate-no="plateNo"/>

    <van-back-top />
</div>
</template>

<style lang="less">
    .favo{
        display: block;
        min-height: 300px;
        padding-top: 65px;

        .asynDate{
            text-align: center;
            padding:10px;
            font-size: 14px;
        }
        
        .favoPagetitle{
            font-size: 20px;
            font-weight: bold;
            padding:20px;    
            position: fixed;
            top: 0;
            width: 100%;
            z-index: 1;
            background: #fff;            
            border-bottom: 1px solid #f2f2f2;
            display: flex;
            height: 60px;
            align-items: center;
        }

      

        .carBakInfo{
            background-color: #fff;
            padding:10px;
        }
        
        .content{
            
            padding:10px;
            padding-top: 0;
            min-height: 400px;
            .loadMore{
                width: 100%;
                font-size: 12px;
                color: #4385f5;
                text-align: center;
                margin: 0.5rem auto 1rem;
            }
        }

        .carInfoContent{
            background-color: #fff;
            margin-bottom:10px;
            padding-left: 10px;
        }

        .carparkitem{
            background-color: #fff;
            margin-bottom: 6px;
        }

    }


</style>

<style lang="css">
   
 @media screen and (min-width: 1024px) {
  
    .favo  .content{
        margin-top: 15px;
        padding-left: 0;
        padding-right: 0;
    }
}
</style>